/**
 * Copyright (c) 2011 Daniel Centore
 *
 * ex: set filetype=java expandtab tabstop=4 shiftwidth=4 :
 * 
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * This code is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation.
 */
package wiiWired.controller.mote;


/**
 * Controls the rotating lights in a single WiiMote.
 * Pretty self-explanatory
 * 
 * @author Daniel Centore
 *
 */
public class TimerLights extends Thread {

	public static final TimerLights instance = new TimerLights();	//the main instance
	
	private static boolean[] led = new boolean[4];
	private static int pos = 0;

	public static void initialize()
	{
		instance.start();
	}

	public static boolean[] getLights()
	{
		return led;
	}

	@Override
	public void run()
	{
		while(true)
		{
			led = new boolean[4];
			led[pos++] = true;


			if(pos >= 4)
				pos = 0;
			
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static void resetLights()
	{
		pos = 0;
	}

}
